﻿using UnityEngine;

namespace E.Story
{
    /// <summary>
    /// UI槽模板类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class UIItem<T> : MonoBehaviour
    {
        [Tooltip("数据")][SerializeField] private T data;

        public T Data { get => data; }

        /// <summary>
        /// 设置数据并自动刷新
        /// </summary>
        /// <param name="data">数据</param>
        public void SetData(T data)
        {
            this.data = data;
            Refresh();
        }

        /// <summary>
        /// 刷新
        /// </summary>
        public abstract void Refresh();
    }
}
